package org.example;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServer;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.proxy.handler.ProxyHandler;
import io.vertx.httpproxy.HttpProxy;

public class ProxyRerank extends AbstractVerticle {

    @Override
    public void start(Promise<Void> startPromise) throws Exception {
        HttpClient proxyClient = vertx.createHttpClient();
        HttpProxy httpProxy = HttpProxy.reverseProxy(proxyClient);
        httpProxy.origin(6000, "10.111.14.112");
        HttpServer proxyServer = vertx.createHttpServer();
        Router proxyRouter = Router.router(vertx);
        proxyRouter.route(HttpMethod.POST, "/*").handler(ProxyHandler.create(httpProxy));
        proxyServer.requestHandler(proxyRouter);
        proxyServer.listen(6000);
        System.out.println("初始化Rerank代理完成");
    }
}
